package com.syxp.pda.service.standard.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.springframework.transaction.annotation.Transactional;

import com.syxp.pda.core.dao.BaseDao;
import com.syxp.pda.core.service.impl.BaseServiceImpl;
import com.syxp.pda.dao.base.DefineIDZoneDao;
import com.syxp.pda.dao.base.DeviceBaseInfoDao;
import com.syxp.pda.dao.base.ProfessDao;
import com.syxp.pda.entity.base.CHKLine;
import com.syxp.pda.entity.base.DefineIDZone;
import com.syxp.pda.entity.base.DeviceBaseInfo;
import com.syxp.pda.entity.base.Profess;
import com.syxp.pda.entity.standard.DeviceCheckStandard;
import com.syxp.pda.service.standard.DeviceCheckStandardService;

@Transactional
public class DeviceCheckStandardServiceImpl extends BaseServiceImpl<DeviceCheckStandard> implements
DeviceCheckStandardService {

	private ProfessDao professDao;
	private DefineIDZoneDao defineIDZoneDao;
	private DeviceBaseInfoDao deviceBaseInfoDao;
	
	public DeviceCheckStandardServiceImpl(BaseDao<DeviceCheckStandard> baseDao) {
		super(baseDao);
	}

	public List<DeviceCheckStandard> getDeviceCheckStandard(int deviceInfoId) {
		DeviceBaseInfo deviceBaseInfo = this.deviceBaseInfoDao.get(deviceInfoId);
		Set<DeviceCheckStandard> set = deviceBaseInfo.getDeviceCheckStandards();
		List list = new ArrayList();
		list.addAll(set);
		return list;
	}
	

	@Override
	public List<DefineIDZone> getZones(int professId) {
		List<DefineIDZone> list = new ArrayList<DefineIDZone>();
		Profess profess = this.professDao.get(professId);
		Set<CHKLine> lines = profess.getLines();
		for(CHKLine line: lines) {
			Set<DefineIDZone> zones = line.getDefineIDZones();
			list.addAll(zones);
		}
		return list;
	}

	@Override
	public List<DeviceBaseInfo> getDevices(int zoneId) {
		List<DeviceBaseInfo> list = new ArrayList<DeviceBaseInfo>();
		DefineIDZone zone = this.defineIDZoneDao.get(zoneId);
		Set<DeviceBaseInfo> devices = zone.getDevices();
		list.addAll(devices);
		return list;
	}


	/**
	 * @return the professDao
	 */
	public ProfessDao getProfessDao() {
		return professDao;
	}

	/**
	 * @param professDao the professDao to set
	 */
	public void setProfessDao(ProfessDao professDao) {
		this.professDao = professDao;
	}

	/**
	 * @return the defineIDZoneDao
	 */
	public DefineIDZoneDao getDefineIDZoneDao() {
		return defineIDZoneDao;
	}

	/**
	 * @param defineIDZoneDao the defineIDZoneDao to set
	 */
	public void setDefineIDZoneDao(DefineIDZoneDao defineIDZoneDao) {
		this.defineIDZoneDao = defineIDZoneDao;
	}

	/**
	 * @return the deviceBaseInfoDao
	 */
	public DeviceBaseInfoDao getDeviceBaseInfoDao() {
		return deviceBaseInfoDao;
	}

	/**
	 * @param deviceBaseInfoDao the deviceBaseInfoDao to set
	 */
	public void setDeviceBaseInfoDao(DeviceBaseInfoDao deviceBaseInfoDao) {
		this.deviceBaseInfoDao = deviceBaseInfoDao;
	}

}
